using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using RaisingStudio.Xna.Graphics;

namespace MonoGame1
{
	public class Game5 : Game
	{
		GraphicsDeviceManager graphics;
		private DrawingContext drawingContext;
		private SpriteBatch spriteBatch;
		private SpriteFont spriteFont;
		private Texture2D texture;

        public Game5()
		{
			graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";
		}
		
		protected override void LoadContent ()
		{
            this.drawingContext = new DrawingContext(this.GraphicsDevice);
            this.spriteBatch = new SpriteBatch(this.GraphicsDevice);
			
			this.spriteFont = Content.Load<SpriteFont>("SegoeUI");
			this.texture = Content.Load<Texture2D>("Tulips");
		}
		
		protected override void Update (GameTime gameTime)
		{
			base.Update (gameTime);
		}
		
		protected override void Draw (GameTime gameTime)
		{
			GraphicsDevice.Clear(Color.White);
			
			this.drawingContext.Begin();
			//this.drawingContext.DrawLine(10, 10, 100, 100, Color.Red);
			this.drawingContext.DrawTexture(this.texture, new Vector2(10, 10), Color.White);
			this.drawingContext.DrawText(this.spriteFont, "Hello World!", new Vector2(100, 20), Color.Blue);
			
			this.drawingContext.DrawPoints(new Vector2[]{new Vector2(200, 200), new Vector2(201, 201), new Vector2(202, 202)}, Color.Red);
			int count = 10;
			Color[] colors = new Color[count * count];
			for (int i = 0; i < count; i++)
			{
				colors[i] = new Color(i, i, i);
			}
			this.drawingContext.DrawColors(colors, new Vector2(count, count), new Vector2(300, 300));
			this.drawingContext.DrawColors(new VertexPositionColor[] {new VertexPositionColor(new Vector3(400, 400, 0), Color.Green), new VertexPositionColor(new Vector3(401, 400, 0), Color.Green), new VertexPositionColor(new Vector3(402, 400, 0), Color.Green)});

            Color[] data = new Color[count * count];            
            TextureContext textureContext = new TextureContext(data, count, count);
            textureContext.Begin();
            textureContext.DrawLine(0, 0, 0, count, Color.Pink);
            textureContext.End();
            this.drawingContext.DrawColors(data, new Vector2(count, count), new Vector2(400, 100));


            Texture2D dataTexture = new Texture2D(GraphicsDevice, 100, 100);
            TextureContext t2 = new TextureContext(dataTexture);
            t2.Begin();
            t2.DrawLine(1, 1, 100, 1, Color.Blue);
            t2.DrawRectangle(2, 3, 96, 96, Color.Green);
            t2.DrawRectangle(4, 4, 92, 36, Color.Red);
            t2.DrawTriangle(35, 5, 6, 65, 60, 80, Color.Black); 
            t2.End();
            this.drawingContext.DrawTexture(dataTexture, new Vector2(500, 100), Color.White);


			this.drawingContext.End();


			
			this.spriteBatch.Begin();
			//this.spriteBatch.Draw(this.texture, new Vector2(10, 10), Color.White);
			//this.spriteBatch.DrawString(this.spriteFont, "Hello World!", new Vector2(100, 20), Color.Blue);
			this.spriteBatch.End();
			                     
	
			base.Draw (gameTime);
		}
	}
}

